/**
* DSPengLai - Championship helper
* Copyright (C) 2008  Crisanto, Israel
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*/

#ifndef _PLAYER_HPP_
#define _PLAYER_HPP_

#include <nds.h>
#include <vector>
#include <string.h>     //memset

/**
*
*/
typedef struct Player {
   char name[10];
   char group[100];
   float notes[5];
   float fault;
   float final;
   Player(const char* n) {
      strcpy(name, n);
      for( int x = 0; x < 5; x++ )
         notes[x] = 0;

      final = 0;
      fault = 0;
      strcpy(group, "Desconhecido");
   }

   Player(const char* n, const char* g) {
      strcpy(name, n);
      for( int x = 0; x < 5; x++ )
         notes[x] = 0;

      final = 0;
      fault = 0;
      strcpy(group, g);
   }

   int getHigh(void) {
      int h = 0;
      int x;
      for( x = 0; x < 5; x++) {
         if(notes[x] > notes[h])
            h = x;
      }

      return h;
   }

   int getLow(void) {
      int l = 0;
      int x;
      for( x = 0; x < 5; x++) {
         if(notes[x] < notes[l])
            l = x;
      }
      return l;
   }

   float getPondMedia( void) {
        float m = 0;
        for( int x = 0; x < 5; x++ ){ 
           if( (x != getHigh()) && (x != getLow()) ) {
               m += notes[x];
           }
        }

        return (m / 3) - fault;
   }
} Player;

/**
*
*/
typedef struct PlayerList {
   char catName[70];
   std::vector<Player> players;
} PlayerList;


#endif //~ _PLAYER_HPP_